import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () =>
    import ('views/home/Home.vue')
const HomeCate = () =>
    import ('views/home/HomeCate.vue')

const Category = () =>
    import ('views/category/Category.vue')
const List = () =>
    import ('views/category/List.vue')
const GoodsList = () =>
    import ('views/category/GoodsList.vue')

const Buy = () =>
    import ('views/Buy.vue')
const Cart = () =>
    import ('views/cart/Cart.vue')
const Profile = () =>
    import ('views/Profile.vue')
const Detail = () =>
    import ('views/detail/Detail.vue')

const routes = [{
        path: '',
        redirect: '/home/itemlist/1005000'
    },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        children: [{
            path: 'itemlist/:id',
            component: HomeCate
        }]
    },
    {
        path: '/category',
        name: 'Category',
        component: Category,
        children: [{
            path: 'list/:id',
            component: List
        }]
    },
    {
        path: '/buy',
        name: 'Buy',
        component: Buy
    },
    {
        path: '/cart',
        name: 'Cart',
        component: Cart
    },
    {
        path: '/profile',
        name: 'Profile',
        component: Profile
    },
    {
        path: '/goodslist/:categoryId/:subCategoryId',
        name: 'GoodsList',
        component: GoodsList
    },
    {
        path: '/detail/:id',
        name: 'Detail',
        component: Detail
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router